//
//  CartButton.m
//  Dresshere
//
//  Created by ZhangPeng on 2018/1/18.
//  Copyright © 2018年 张朋. All rights reserved.
//

#import "CartButton.h"

@implementation CartButton

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self.numberButton = [[UIButton alloc] initWithFrame:CGRectMake(0, (self.height-20)/2, 20, 20)];
        self.numberButton.userInteractionEnabled = NO;
        [self.numberButton setTitle:@"0" forState:UIControlStateNormal];
        [self.numberButton setBackgroundImage:[UIImage imageNamed:@"shopping_cart_number"] forState:UIControlStateNormal];
        self.numberButton.titleLabel.font = [UIFont systemFontOfSize:14];
        [self.numberButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        
        UIImageView *imgView = [[UIImageView alloc] initWithFrame:CGRectMake(self.numberButton.right, 0, frame.size.width - 20, frame.size.height)];
        [imgView setImage:[UIImage imageNamed:@"cart"]];
        imgView.contentMode = UIViewContentModeCenter;
        imgView.clipsToBounds = YES;
        
        [self addSubview:self.numberButton];
        [self addSubview:imgView];
    }
    return self;
}

@end
